const {API, COMM} = getApp()

Component({

  /**
   * 组件的属性列表
   */
  properties: {
    // 属性的类型可以为 String Number Boolean Object Array 其一，也可以为 null 表示不限制类型。
    imgUrl: {
        type: String,
        observer: 'obfullImgUrl'
    },
    fullImgUrl: String,
    title: String,
    originPrice: String,
    bonusPrice: {
        type: String,
        observer: 'bonusPrice'
    },
    isBonus: {
        type: Boolean,
        value: false
    },
    shelf: String,
    inventry: String,
    saleNum: Number,
    txm: String,
  },

  /**
   * 组件的初始数据
   */
  data: {
    desc: ""
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onClick() {
        // console.log(`---this.data.txm:${this.data.txm}-----`)
        wx.navigateTo({
          url: '/pages/goods/detail/index?txm=' + this.data.txm,
        })
    },
    onFavoritesClick() {
        console.log('--------onFavoritesClick---------')
    },
    bonusPrice(newVal, oldVal) {
        if (newVal && newVal !== '') {
            this.setData({
                isBonus: true,
            });
        }
    },
    obfullImgUrl(newVal, oldVal) {
        this.setData({
            fullImgUrl: COMM.baseUrl + COMM.apiList.Image + "/" + newVal
        })
    }
  },

})